'''
Created on Mar 21, 2012

@author: Vu Dao
'''

from Interface.loginPage import idTxtUsername, nameTxtPassword, nameBtnLogin
from selenium import webdriver

# Open a Web site
def openWebsite(self):
    sel = self.selenium
    sel.open("http://localhost/index.php")
    sel.wait_for_page_to_load(60000)
    
# Login web site
def login(self,username,password):
#    browser = webdriver.Firefox()
    browser = self.browser
    elem = browser.find_element_by_id(idTxtUsername())
    elem.send_keys(username)
    
    elem = browser.find_element_by_name(nameTxtPassword())
    elem.send_keys(password)
    
    elem = browser.find_element_by_name(nameBtnLogin())
    elem.click()
    browser.implicitly_wait(30)
# Verify login website
def isLoginSuccessfully(self):
    sel = self.selenium
    try:
        self.failUnless(sel.is_text_present("Home"))
        return True
    except AssertionError, e:
        self.verificationErrors.append(str(e))
        return False
        
        
   

    
